package com.curry.android.util;

import android.widget.ImageView;

import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * Created by Administrator on 2015/12/14.
 * 异步加载图片工具类
 */
public class LocalImageLoadUtil {
    private static LocalImageLoadUtil loadUtil;
    public static synchronized LocalImageLoadUtil getInstance(){
        if(loadUtil==null){
            loadUtil = new LocalImageLoadUtil();
        }
        return loadUtil;
    }

    /**
     * 从内存卡中异步加载本地图片
     * @param uri
     * @param imageView
     */
    public void displayFromSDCard(String uri,ImageView imageView){
        ImageLoader.getInstance().displayImage("file://"+uri,imageView);
    }

    /**
     * 从assets文件中异步加载图片
     * @param imageName
     * @param imageView
     */
    public void displayFromAssets(String imageName,ImageView imageView){
        ImageLoader.getInstance().displayImage("assets://"+imageName,imageView);
    }

    /**
     * 从drawable中异步加载图片
     * @param imageId
     * @param imageView
     */
    public void displayFromDrawable(int imageId,ImageView imageView){
        ImageLoader.getInstance().displayImage("drawable://"+imageId,imageView);
    }

    /**
     * 从内容提供者中抓取图片
     * @param uri
     * @param imageView
     */
    public void displayFromContent(String uri,ImageView imageView){
        ImageLoader.getInstance().displayImage("content://"+uri,imageView);
    }
}
